/*
 * Deptree.h
 *
 *  Created on: Dec 18, 2014
 *      Author: Phong
 */

#ifndef DEPTREE_H_
#define DEPTREE_H_

#include "Dictionary.h"
#include <string>
#include "Matrix.h"
using namespace std;

class Depstruct;

class Deptree {
public:
	int nNodes;
	int *word, *pos, *cap, *parent, *dir, *deprel;
	int** nChildren;
	int*** children;
    Depstruct* ds;
    int refCount;

    // temp arrays for training + parsing
    Matrix** outer;
    Matrix** pOuter;
    Matrix*** EOCOuter;
    Matrix** gradO;
    Matrix** gradpO;
    Matrix*** gradEOCO;
    
    Matrix** gZdr;
    Matrix** gZpos;
    Matrix** gZword;
    Matrix** gZcap;
    Matrix*** gZ_EOC;
    
    Matrix*** phraseISums;
    Matrix*** sums;

    Matrix** gradheadI;
    Matrix** gradphraseI;
    Matrix** headInner;
    Matrix** phraseInner;
    
    Matrix** deprelProb;
    Matrix** posProb;
    Matrix** capProb;
    Matrix** wordProb;
    Matrix*** EOCProb;

	Deptree(int nWords);
    Deptree* share();
    static void free(Deptree* tree);
    void freeTempArrays();
    
 	string toString(Dictionary* vocaDic, Dictionary* posDic, Dictionary* deprelDic);

private:
    ~Deptree();
};

#endif /* DEPTREE_H_ */
